
#ifndef LOG_H
#define LOG_H

#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/syscall.h>
#define gettid() syscall(SYS_gettid)

static unsigned long long get_time()
{
    struct timeval cur;
    long timems = 0;
    gettimeofday(&cur, NULL);
    timems = cur.tv_sec * 1000 + (cur.tv_usec) / 1000;
    return timems;
}

#define LOGD(fmt, args...)                                                               \
    do                                                                                   \
    {                                                                                    \
        printf("%llu %d %s:%d: " fmt, get_time(), (int)gettid(), __FILE__, __LINE__, ##args); \
        printf("\n");                                                                    \
    } while (0)

#endif // LOG_H
